package com.momo.controller;

import com.momo.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author ：朱博
 * @description：TODO
 * @date ：2021/3/7 13:18
 */
@Controller
public class HelloVelocityController {
        @RequestMapping("/showAllUser")
        public String showAllUser(HttpServletRequest request, Model model){
            System.out.println("123");
            //volicaty放入集合
            List<User> list = new ArrayList<User>();
            User user = new User();
            user.setAge(1);
            user.setDate(new Date());
            user.setId(1);
            user.setName("张三");
            User user2 = new User();
            user2.setAge(1);
            user2.setDate(new Date());
            user2.setId(1);
            user2.setName("李四");
            list.add(user);
            list.add(user2);
            model.addAttribute("userList",list);
            //放入单个数据
            model.addAttribute("user","测试数据");
            return "showAllUser";
        }
}
